package com.lhb.aicodemother.model.enums;

import cn.hutool.core.util.ObjUtil;
import lombok.Getter;

/*
* 历史对话 消息类型枚举
* */
@Getter
public enum ChatHistoryMessageTypeEnum {
    USER("用户","user"),
    AI("AI","ai");

    private String text;
    private String value;

    ChatHistoryMessageTypeEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    /*
    * 根据值来获取枚举
    * */
    public static ChatHistoryMessageTypeEnum getEnumByValue(String value) {
        if(ObjUtil.isEmpty(value)){
            return null;
        }
        for (ChatHistoryMessageTypeEnum chatHistoryMessageTypeEnum : ChatHistoryMessageTypeEnum.values()) {
            if (chatHistoryMessageTypeEnum.getValue().equals(value)) {
                return chatHistoryMessageTypeEnum;
            }
        }
        return null;
    }
}
